package ming.model.type;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;


@SuppressWarnings("serial")
@Entity
@Table(name = "T_QUESTIONNAIRE_TABLESANSWER", catalog = "")
public class Tablesanswer implements java.io.Serializable {

	// Fields

	private String id;
	private Tables tables;//问题表格
	private String question;
	private String answer;
	private Integer seq;
	private Set<Tableslog> tableslogs = new HashSet<Tableslog>(0);


	// Property accessors
	@Id
	@Column(name = "vcId", unique = true, nullable = false, length = 36)
	public String getId() {
		if (!StringUtils.isBlank(this.id)) {
			return this.id;
		}
		return UUID.randomUUID().toString();
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "vcTablesId")
	public Tables getTables() {
		return this.tables;
	}

	public void setTables(Tables tables) {
		this.tables = tables;
	}

	@Column(name = "vcQuestion", length = 500)
	public String getQuestion() {
		return question;
	}

	public void setQuestion(String question) {
		this.question = question;
	}

	@Column(name = "vcAnswer", length = 200)
	public String getAnswer() {
		return this.answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}

	@Column(name = "intSeq")
	public Integer getSeq() {
		return seq;
	}

	public void setSeq(Integer seq) {
		this.seq = seq;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "tablesanswer")
	public Set<Tableslog> getTableslogs() {
		return this.tableslogs;
	}

	public void setTableslogs(Set<Tableslog> tableslogs) {
		this.tableslogs = tableslogs;
	}

}